#include "tlog.h"

#define TAG "TLOG"

/**
 * @brief   设置log等级状态
 * @param   TLOG_LEVEL_T type  需要设置的log类型
 * @param   TLOG_STATE_T state 需要设置成的状态
 * @retval  void
 * @note
 */
void tlog_set_log_level_state(TLOG_LEVEL_T type, TLOG_STATE_T state) {
  switch (type) {
    case TLOG_ERROR_LEVEL:
      TLOG_ERROR_FLAG = state;
      break;
    case TLOG_WARNING_LEVEL:
      TLOG_WARNING_FLAG = state;
      break;
    case TLOG_INFO_LEVEL:
      TLOG_INFO_FLAG = state;
      break;
    case TLOG_DEBUG_LEVEL:
      TLOG_DEBUG_FLAG = state;
      break;
    case TLOG_TRACE_LEVEL:
      TLOG_TRACE_FLAG = state;
      break;

    default:
      TLOGI(TAG, "Not find TLOG LEVEL\n");
      break;
  }
}

/**
 * @brief   获取log等级状态
 * @param   TLOG_LEVEL_T type  需要获取的log类型
 * @retval  TLOG_STATE_T 返回log类型的状态
 * @note    如果未找到log类型(报错)则返回TLOG_STATE_TOTAL
 */
TLOG_STATE_T tlog_get_log_level_state(TLOG_LEVEL_T type) {
  switch (type) {
    case TLOG_ERROR_LEVEL:
      return TLOG_ERROR_FLAG;
      break;
    case TLOG_WARNING_LEVEL:
      return TLOG_WARNING_FLAG;
      break;
    case TLOG_INFO_LEVEL:
      return TLOG_INFO_FLAG;
      break;
    case TLOG_DEBUG_LEVEL:
      return TLOG_DEBUG_FLAG;
      break;
    case TLOG_TRACE_LEVEL:
      return TLOG_TRACE_FLAG;
      break;
  }
  TLOGI(TAG, "Not find TLOG LEVEL\n");
  return TLOG_STATE_TOTAL;  // 返回TOTAL表示没有找到对应状态
}